#pragma once

#include "ListDefine.h"

enum DockPosition
{
	DP_NONE = 0,
	DP_LEFT = 400,
	DP_RIGHT,
	DP_TOP,
	DP_BOTTOM
};

class CVNavigatorUI;
class CHNavigatorUI;
class CDicomArchiver;
class CDockableNavigator : public IDialogBuilderCallback
{
public:
	CDockableNavigator();
	~CDockableNavigator();

	virtual CControlUI* CreateControl(LPCTSTR pstrClass);

private:
	CPaintManagerUI* m_pm;
	//CVerticalLayoutUI* m_pLeftNav;
	//CVerticalLayoutUI* m_pRightNav;
	//CHorizontalLayoutUI* m_pTopNav;
	//CHorizontalLayoutUI* m_pBottomNav;

	CVNavigatorUI* m_pLeftNav;
	CVNavigatorUI* m_pRightNav;
	CHNavigatorUI* m_pTopNav;
	CHNavigatorUI* m_pBottomNav;

	mutable std::mutex m_mtxUpd;

	CDicomArchiver* m_pArchiver;
	DockPosition m_pos;

	vector<Node*> m_HLNode;
	DString m_expandImage;
	DString m_collapseImage;

	CDuiRect	m_rcPadding;
	Node*	m_pRootNode;
	bool    m_bVisible;

	Node* GetRoot();

	void SetRoot(Node* root);

	Node* AddNode(Node* node, Node* parent = NULL, int idx = 0);
	void UpdateStudyElem(Node* study);
	void UpdateSeriesElem(Node* series);

	bool IsVertical();

	
public:
	bool OnSizeChanged(void* param);
	void SetNavigators(CVNavigatorUI* lNav, CVNavigatorUI* rNav, CHNavigatorUI* tNav, CHNavigatorUI* bNav);
	void SetArchiver(CDicomArchiver* archiver);
	void SetPaintManager(CPaintManagerUI* pm);
	void DockNavigator(DockPosition pos);
	DockPosition GetDockPosition() { return m_pos; }
	void Update();
	void ReLoad();
	CContainerUI* GetUsedNavigator();

	void RemoveAll();
	void UnBindElement(Node* node);

	void HightLightNode(Node* node, CBaseImage* pImg);

	bool CanExpand(Node* node) const;

	void SetChildVisible(Node* node, int start, bool visible);

	DString GetLevelName(int level);

	bool IsVisible();
	void SetVisible(bool v);
};
